<?php
class Login_Model extends Model {
	
	public $obj = '';
	
    public function __construct()
    {
       	parent::__construct();
       	$this->session = Session::instance();	// init property session use Session 
    }
    
    public function get_obj($obj)
	{
		if($obj == 1) $this->obj = 'sess_cus';
		elseif($obj == 2) $this->obj = 'sess_user';
		elseif($obj == 3) $this->obj = 'sess_tmp';
	}

	public function is_login($obj = 1)
	{
		$this->get_obj($obj);
		if ($this->session->get($this->obj)) {
			return TRUE;
		} else {
			return FALSE;
		}		
	}
	
	public function get_login($obj = 1)
	{
		$this->get_obj($obj);
		
		if ($this->session->get($this->obj)) {
            return $this->session->get($this->obj);
        }
        /*if(isset($_SESSION[$this->obj])){
			return $_SESSION[$this->obj];
		}*/
		return false;
	}
	
	public function set_login($obj = 1, $val)
	{
        $this->session->regenerate();
       
		$this->get_obj($obj);
		
		$this->session->set($this->obj,$val);
        
        //$_SESSION[$this->obj] = $val;
	}
	
	public function unset_login($obj=1)
	{
		$this->get_obj($obj);
		
		$this->session->delete($this->obj);
        //$_SESSION[$this->obj] = '';
        
        $this->session->regenerate();
	}
}
?>